<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" 
type="text/css" href="${pageContext.request.contextPath }/mc/css/index_love.css"></link>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/mc/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/mc/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript">
	$(function () {
		$("#qx").click(function () {
			$(".xz").each(function () {
				this.checked = $("#qx")[0].checked;
			})
		})
	})
	function add() {
		location = "${pageContext.request.contextPath}/toAdd";
	}
	//批量删除
	function delAll() {
		var ids = $(".xz:checked").map(function() {
			return this.value;
		}).get().join(",");
		 alert(ids)
	

	    	if(ids!=''){
	    			$.post("${pageContext.request.contextPath}/delete",{ids:ids}, function(data) {
	    				
	    					if(data.flag){
				    		alert("删除成功");
				    		window.location.href="${pageContext.request.contextPath}/list";
				    	}else{
				    		alert("删除失败")
				    	}
	    				
	    			}, 'json');
	    		}else{
	    			alert("取消删除");
	    		}
	}	
 </script>
<title>Insert title here</title>
</head>
<body>
<input type="button" onclick="add()" value="添加">
<form action="list" method="post">
	<input type="text" name="name" value="${name }">
	<button>搜索</button>
</form>
<table>
		<tr>
			<th><input type="checkbox" id="qx">全选</th>
			<th>用户id</th>
			<th>用户名</th>
			<th>手机号</th>
			<th>用户组</th>
			<th>操作</th>
		</tr>
		
	<c:forEach items="${lvList }" var="lv">
		<tr>
			<td><input type="checkbox" class="xz" value="${lv.cid }"></td>
			<td>${lv.cid }</td>
			<td>${lv.cname }</td>
			<td>${lv.cphone }</td>
			<td>${lv.tnames }</td>
			<td>
				<a href="look?cid=${lv.cid }">查看</a>
				<a href="toUpdate?cid=${lv.cid }">编辑</a>
			</td>
		</tr>
	</c:forEach>
		<tr>
			<td colspan="10">
				<a href="${pageContext.request.contextPath}/list?page=1">首页</a>
				<a href="${pageContext.request.contextPath}/list?page=${page-1<1?1:page-1 }">上一页</a>
				<a href="${pageContext.request.contextPath}/list?page=${page+1>pages?pages:page+1 }">下一页</a>
				<a href="${pageContext.request.contextPath}/list?page=${pages }">末页</a>
				${page }/${pages }  共${count }条
				<input type="button" onclick="delAll()" value="批量删除" >
			</td>
		</tr>
	
</table>
</body>
</html>